﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace ShevaEngine.Core.Modules.Animations
{
    /// <summary>
    /// A collection of SkinInfo objects.
    /// </summary>
    [ContentSerializerRuntimeTypeAttribute("ShevaEngine.Core.Modules.Animations.SkinInfoCollection, ShevaEngine2")]
    public class SkinInfoCollection : List<SkinInfo>
    {
        /// <summary>
        /// Konstruktor.
        /// </summary>
        public SkinInfoCollection()
            : base()
        {
        }

        /// <summary>
        /// Finds the skinning info for the model and calculates the inverse
        /// reference poses required for animation.
        /// </summary>
        /// <param name="model">The model that contains the skinning info.</param>
        /// <returns>A collection of SkinInfo objects.</returns>
        public static SkinInfoCollection FromModel(Model model)
        {
            // This is created in the content pipeline
            Dictionary<string, object> modelTagData =
                    (Dictionary<string, object>)model.Tag;
            // An array of bone names that are used by the palette
            SkinInfoCollection[] info = (SkinInfoCollection[])modelTagData["SkinInfo"];
            return info[0];
        }
    }
}
